#include <linux/sched.h>
#include <linux/sched/task.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/pid.h>
#include <linux/err.h>

static int idle_dummy(void *dummy)
{
    /* This function is never called */
    return 0;
}

__init int fork_idle(int cpu, struct task_struct **tsk_ret)
{
    struct kernel_clone_args args = {
        .flags = CLONE_VM,
        .fn = &idle_dummy,
        .fn_arg = NULL,
        .kthread = 1,
        .idle = 1,
    };
    int err;

    err = copy_process(NULL, 0, cpu, &args, tsk_ret);
    if (err == 0)
    {
        init_idle(*tsk_ret, cpu);
    }

    return err;
}
